# 递归函数求阶乘
def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)

# 调用函数
print(factorial(5)) # 120